package io.geekidea.springbootplus.system.service.impl;

import io.geekidea.springbootplus.system.entity.ParcelCenterCo;
import io.geekidea.springbootplus.system.mapper.ParcelCenterCoMapper;
import io.geekidea.springbootplus.system.service.ParcelCenterCoService;
import io.geekidea.springbootplus.system.param.ParcelCenterCoPageParam;
import io.geekidea.springbootplus.system.vo.ParcelCenterCoQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.Serializable;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
/**
 *  服务实现类
 *
 * @author miko
 * @since 2020-10-24
 */
@Slf4j
@Service
public class ParcelCenterCoServiceImpl extends BaseServiceImpl<ParcelCenterCoMapper, ParcelCenterCo> implements ParcelCenterCoService {

    @Autowired
    private ParcelCenterCoMapper parcelCenterCoMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveParcelCenterCo(ParcelCenterCo parcelCenterCo) throws Exception {
        return super.save(parcelCenterCo);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateParcelCenterCo(ParcelCenterCo parcelCenterCo) throws Exception {
        return super.updateById(parcelCenterCo);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteParcelCenterCo(Long id) throws Exception {
        return super.removeById(id);
    }


    @Override
    public List<ParcelCenterCo> getAllList(LambdaQueryWrapper<ParcelCenterCo> wrapper) throws Exception{
        return parcelCenterCoMapper.selectList(wrapper);
    }



    @Override
    public ParcelCenterCoQueryVo getParcelCenterCoById(Serializable id) throws Exception {
    return parcelCenterCoMapper.getParcelCenterCoById(id);
    }

    @Override
    public Paging<ParcelCenterCoQueryVo> getParcelCenterCoPageList(ParcelCenterCoPageParam parcelCenterCoPageParam) throws Exception {
        Page<ParcelCenterCoQueryVo> page = new PageInfo<>(parcelCenterCoPageParam, OrderItem.desc(getLambdaColumn(ParcelCenterCo::getCreateTime)));
        IPage<ParcelCenterCoQueryVo> iPage = parcelCenterCoMapper.getParcelCenterCoPageList(page, parcelCenterCoPageParam);
        return new Paging<ParcelCenterCoQueryVo>(iPage);
    }

}
